package charpter12.lynx;


class Annoyance extends RuntimeException {
}

class Sneeze extends Annoyance {
}

class WrapCheckedException {
	void throwRuntimeException(int type) {
		try {
			switch (type) {
			case 0:
				throw new Sneeze();
			case 1:
				throw new Annoyance();
			default:
				return;
			}
		} catch (Exception e) { // Adapt to unchecked:
			throw new RuntimeException(e);
		}
	}
}

public class Thirty {
	public static void main(String[] args) throws Throwable {
		for (int i = 0; i < 2; i++) {
			try {

				new WrapCheckedException().throwRuntimeException(i);

			} catch (RuntimeException e) {
				try {
					throw e.getCause();
				} catch (Sneeze s) {
					System.out.println("Caught Sneeze");
				} catch (Annoyance a) {
					System.out.println("Caught Annoyance");
				}
			}
		}
	}
}
